package com.hwj.controller;


import com.hwj.utils.JsonResponse;
import com.yupi.yucongming.dev.client.YuCongMingClient;
import com.yupi.yucongming.dev.common.BaseResponse;
import com.yupi.yucongming.dev.model.DevChatRequest;
import com.yupi.yucongming.dev.model.DevChatResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/ai")
public class AIDoctorController {
    private static final YuCongMingClient client = new YuCongMingClient("zx29w270gu8ks9xm6kjeu0ziaab80mzj", "z04r4nc0db090t8kvo69sou9c2dt77wj");
    private static final DevChatRequest devChatRequest = new DevChatRequest();
    @PostMapping
    public JsonResponse main(@RequestBody Map<String,String> messageEntity){
        String message=messageEntity.get("message");
        devChatRequest.setModelId(1772277466082566145L);
        devChatRequest.setMessage(message);
        BaseResponse<DevChatResponse> response = client.doChat(devChatRequest);
        System.out.println(response.getData());
        return JsonResponse.successResponse(0,
                "ai回答成功",response.getData().getContent());
    }
}
